package aspect.example;
import aspect.util.Angles;
import aspect.entity.behavior.Behavior;
import static aspect.core.AspectLauncher.*;
import static aspect.core.AspectRenderer.*;
import static aspect.resources.Resources.*;
import aspect.util.Vector3;
import aspect.event.MouseEvent;
import aspect.physics.Time;
import aspect.render.Material;
import aspect.render.ViewModel;
import java.io.File;
import static org.lwjgl.input.Keyboard.*;
public class InputDemo extends Behavior {
private ViewModel cube;
private Vector3 pos = new Vector3(0, 0, -4);
private Angles ang = Angles.zero();
public static void main(String[] args) {
run(800, 600, false, 60, new InputDemo());
}
@Override
public void onAdd() {
Material material = loadMaterial(new File("textures/tex.jpg"));
cube = box(material, 1, 1, 1);
addMouseListener(this);
}
@Override
public void update() {
if (isKeyDown(KEY_LEFT) || isKeyDown(KEY_A)) {
pos.x -= 1 * Time.deltaTime();
}
if (isKeyDown(KEY_RIGHT) || isKeyDown(KEY_D)) {
pos.x += 1 * Time.deltaTime();
}
if (isKeyDown(KEY_UP) || isKeyDown(KEY_W)) {
pos.y += 1 * Time.deltaTime();
}
if (isKeyDown(KEY_DOWN) || isKeyDown(KEY_S)) {
pos.y -= 1 * Time.deltaTime();
}
}
@Override
public void mouseEvent(MouseEvent evt) {
if (evt.button == 0 && evt.type) {
ang.roll += 360 * Time.deltaTime();
}
if (evt.button == 1 && evt.type) {
ang.roll -= 360 * Time.deltaTime();
}
ang.pitch += evt.wheel * Time.deltaTime();
}
@Override
public void render() {
draw3D(cube, pos, ang);
}
}